APM.ConfigSysupgradeController = Ember.Controller.extend({
	form: {
		upgradeFile:"",
		version:"0.0.1",
		model:"ISO9001",
		confType:"14"
	},    
	
	checkFormValid: function(){
		var form = this.get("form");

		this.set("saveResult", null);
		
		if( form.upgradeFile == "" ){
			this.set("formTip", "请选择要导入的升级文件!");
			return false;
		}
		this.set("formTip", null);
		return true;
	},
	
	actions: {
		reset : function() {
			this.set("formTip", null);
			this.set("saveResult", null);
		},
		
		currentVersion: function(){
			alert("当前版本");
			var ctrl = this;
			this.store.ajax("POST", "configs/systemConfig", {
				confType:form.confType
			});
		},
		
		keepConfig:function(){
			alert("保留配置");
			var ctrl = this;
			this.store.ajax("POST", "configs/systemConfig", {
				confType:form.confType
			});
		},
		
		startUpgrade:function(){
			alert("开始升级");
			var ctrl = this;
			this.store.ajax("POST", "configs/systemConfig", {
				confType:form.confType
			});
		},
		
		upgradeFile: function(){
			if( !this.checkFormValid() ){
				return;
			}
			alert("升级文件");
			var ctrl = this;
			var form = this.get("form");

			ctrl.set("saveResult", null);

			this.store.ajax("POST", "configs/systemConfig", {
				
				
			}).then(function(response){
				if(response.status=="success"){
					//todo: 保存成功逻辑
					ctrl.set("saveResult", "修改成功！");
				}
			}, function(){
				ctrl.set("saveResult", "修改失败！");
			});
		}
	}
	
});